home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / cbuster.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  24KB  |  651 lines

  1. /***************************************************************************
  2.  
  3.   Crude Buster (World version FX)        (c) 1990 Data East Corporation
  4.   Crude Buster (World version FU)        (c) 1990 Data East Corporation
  5.   Crude Buster (Japanese version)        (c) 1990 Data East Corporation
  6.   Two Crude (USA version)                (c) 1990 Data East USA
  7.  
  8.   The 'FX' board is filled with 'FU' roms except for the 4 program roms,
  9.   both boards have 'export' stickers which usually indicates a World version.
  10.   Maybe one is a UK or European version.
  11.  
  12.   Emulation by Bryan McPhail, mish@tendril.co.uk
  13.  
  14. ***************************************************************************/
  15.  
  16. #include "driver.h"
  17. #include "vidhrdw/generic.h"
  18. #include "cpu/h6280/h6280.h"
  19.  
  20. int  twocrude_vh_start(void);
  21. void twocrude_vh_stop(void);
  22. void twocrude_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  23.  
  24. WRITE_HANDLER( twocrude_pf1_data_w );
  25. WRITE_HANDLER( twocrude_pf2_data_w );
  26. WRITE_HANDLER( twocrude_pf3_data_w );
  27. WRITE_HANDLER( twocrude_pf4_data_w );
  28. WRITE_HANDLER( twocrude_control_0_w );
  29. WRITE_HANDLER( twocrude_control_1_w );
  30. WRITE_HANDLER( twocrude_palette_24bit_rg_w );
  31. WRITE_HANDLER( twocrude_palette_24bit_b_w );
  32. READ_HANDLER( twocrude_palette_24bit_rg_r );
  33. READ_HANDLER( twocrude_palette_24bit_b_r );
  34.  
  35. WRITE_HANDLER( twocrude_pf1_rowscroll_w );
  36. WRITE_HANDLER( twocrude_pf2_rowscroll_w );
  37. WRITE_HANDLER( twocrude_pf3_rowscroll_w );
  38. WRITE_HANDLER( twocrude_pf4_rowscroll_w );
  39.  
  40. extern unsigned char *twocrude_pf1_rowscroll,*twocrude_pf2_rowscroll;
  41. extern unsigned char *twocrude_pf3_rowscroll,*twocrude_pf4_rowscroll;
  42. extern unsigned char *twocrude_pf1_data, *twocrude_pf2_data, *twocrude_pf3_data, *twocrude_pf4_data;
  43. static unsigned char *twocrude_ram;
  44. extern void twocrude_pri_w(int pri);
  45. WRITE_HANDLER( twocrude_update_sprites_w );
  46. static int prot;
  47.  
  48. /******************************************************************************/
  49.  
  50. static WRITE_HANDLER( twocrude_control_w )
  51. {
  52.     switch (offset) {
  53.     case 0: /* DMA flag */
  54.         twocrude_update_sprites_w(0,0);
  55.         return;
  56.  
  57.     case 6: /* IRQ ack */
  58.         return;
  59.  
  60.     case 2: /* Sound CPU write */
  61.         soundlatch_w(0,data & 0xff);
  62.         cpu_cause_interrupt(1,H6280_INT_IRQ1);
  63.         return;
  64.  
  65.     case 4: /* Protection, maybe this is a PAL on the board?
  66.  
  67.             80046 is level number
  68.             stop at stage and enter.
  69.             see also 8216..
  70.  
  71.                 9a 00 = pf4 over pf3 (normal) (level 0)
  72.                 9a f1 =  (level 1 - water), pf3 over ALL sprites + pf4
  73.                 9a 80 = pf3 over pf4 (Level 2 - copter)
  74.                 9a 40 = pf3 over ALL sprites + pf4 (snow) level 3
  75.                 9a c0 = doesn't matter?
  76.                 9a ff = pf 3 over pf4
  77.  
  78.             I can't find a priority register, I assume it's tied to the
  79.             protection?!
  80.  
  81.         */
  82.         if ((data&0xffff)==0x9a00) prot=0;
  83.         if ((data&0xffff)==0xaa) prot=0x74;
  84.         if ((data&0xffff)==0x0200) prot=0x63<<8;
  85.         if ((data&0xffff)==0x9a) prot=0xe;
  86.         if ((data&0xffff)==0x55) prot=0x1e;
  87.         if ((data&0xffff)==0x0e) {prot=0x0e;twocrude_pri_w(0);} /* start */
  88.         if ((data&0xffff)==0x00) {prot=0x0e;twocrude_pri_w(0);} /* level 0 */
  89.         if ((data&0xffff)==0xf1) {prot=0x36;twocrude_pri_w(1);} /* level 1 */
  90.         if ((data&0xffff)==0x80) {prot=0x2e;twocrude_pri_w(1);} /* level 2 */
  91.         if ((data&0xffff)==0x40) {prot=0x1e;twocrude_pri_w(1);} /* level 3 */
  92.         if ((data&0xffff)==0xc0) {prot=0x3e;twocrude_pri_w(0);} /* level 4 */
  93.         if ((data&0xffff)==0xff) {prot=0x76;twocrude_pri_w(1);} /* level 5 */
  94.  
  95.         break;
  96.     }
  97.     logerror("Warning %04x- %02x written to control %02x\n",cpu_get_pc(),data,offset);
  98. }
  99.  
  100. READ_HANDLER( twocrude_control_r )
  101. {
  102.     switch (offset)
  103.     {
  104.         case 0: /* Player 1 & Player 2 joysticks & fire buttons */
  105.             return (readinputport(0) + (readinputport(1) << 8));
  106.  
  107.         case 2: /* Dip Switches */
  108.             return (readinputport(3) + (readinputport(4) << 8));
  109.  
  110.         case 4: /* Protection */
  111.             logerror("%04x : protection control read at 30c000 %d\n",cpu_get_pc(),offset);
  112.             return prot;
  113.  
  114.         case 6: /* Credits, VBL in byte 7 */
  115.             return readinputport(2);
  116.     }
  117.  
  118.     return 0xffff;
  119. }
  120.  
  121. static READ_HANDLER( twocrude_pf1_data_r ) { return READ_WORD(&twocrude_pf1_data[offset]);}
  122. static READ_HANDLER( twocrude_pf2_data_r ) { return READ_WORD(&twocrude_pf2_data[offset]);}
  123. static READ_HANDLER( twocrude_pf3_data_r ) { return READ_WORD(&twocrude_pf3_data[offset]);}
  124. static READ_HANDLER( twocrude_pf4_data_r ) { return READ_WORD(&twocrude_pf4_data[offset]);}
  125. static READ_HANDLER( twocrude_pf1_rowscroll_r ) { return READ_WORD(&twocrude_pf1_rowscroll[offset]);}
  126. static READ_HANDLER( twocrude_pf2_rowscroll_r ) { return READ_WORD(&twocrude_pf2_rowscroll[offset]);}
  127. static READ_HANDLER( twocrude_pf3_rowscroll_r ) { return READ_WORD(&twocrude_pf3_rowscroll[offset]);}
  128. static READ_HANDLER( twocrude_pf4_rowscroll_r ) { return READ_WORD(&twocrude_pf4_rowscroll[offset]);}
  129.  
  130. /******************************************************************************/
  131.  
  132. static struct MemoryReadAddress twocrude_readmem[] =
  133. {
  134.     { 0x000000, 0x07ffff, MRA_ROM },
  135.     { 0x080000, 0x083fff, MRA_BANK1 },
  136.  
  137.     { 0x0a0000, 0x0a1fff, twocrude_pf1_data_r },
  138.     { 0x0a2000, 0x0a2fff, twocrude_pf4_data_r },
  139.     { 0x0a4000, 0x0a47ff, twocrude_pf1_rowscroll_r },
  140.     { 0x0a6000, 0x0a67ff, twocrude_pf4_rowscroll_r },
  141.  
  142.     { 0x0a8000, 0x0a8fff, twocrude_pf3_data_r },
  143.     { 0x0aa000, 0x0aafff, twocrude_pf2_data_r },
  144.     { 0x0ac000, 0x0ac7ff, twocrude_pf3_rowscroll_r },
  145.     { 0x0ae000, 0x0ae7ff, twocrude_pf2_rowscroll_r },
  146.  
  147.     { 0x0b0000, 0x0b07ff, MRA_BANK2 },
  148.     { 0x0b8000, 0x0b8fff, twocrude_palette_24bit_rg_r },
  149.     { 0x0b9000, 0x0b9fff, twocrude_palette_24bit_b_r },
  150.     { 0x0bc000, 0x0bc00f, twocrude_control_r },
  151.     { -1 }  /* end of table */
  152. };
  153.  
  154. static struct MemoryWriteAddress twocrude_writemem[] =
  155. {
  156.     { 0x000000, 0x07ffff, MWA_ROM },
  157.     { 0x080000, 0x083fff, MWA_BANK1, &twocrude_ram },
  158.  
  159.     { 0x0a0000, 0x0a1fff, twocrude_pf1_data_w, &twocrude_pf1_data },
  160.     { 0x0a2000, 0x0a2fff, twocrude_pf4_data_w, &twocrude_pf4_data },
  161.     { 0x0a4000, 0x0a47ff, twocrude_pf1_rowscroll_w, &twocrude_pf1_rowscroll },
  162.     { 0x0a6000, 0x0a67ff, twocrude_pf4_rowscroll_w, &twocrude_pf4_rowscroll },
  163.  
  164.     { 0x0a8000, 0x0a8fff, twocrude_pf3_data_w, &twocrude_pf3_data },
  165.     { 0x0aa000, 0x0aafff, twocrude_pf2_data_w, &twocrude_pf2_data },
  166.     { 0x0ac000, 0x0ac7ff, twocrude_pf3_rowscroll_w, &twocrude_pf3_rowscroll },
  167.     { 0x0ae000, 0x0ae7ff, twocrude_pf2_rowscroll_w, &twocrude_pf2_rowscroll },
  168.  
  169.     { 0x0b0000, 0x0b07ff, MWA_BANK2, &spriteram },
  170.     { 0x0b4000, 0x0b4001, MWA_NOP },
  171.     { 0x0b5000, 0x0b500f, twocrude_control_1_w },
  172.     { 0x0b6000, 0x0b600f, twocrude_control_0_w },
  173.     { 0x0b8000, 0x0b8fff, twocrude_palette_24bit_rg_w, &paletteram },
  174.     { 0x0b9000, 0x0b9fff, twocrude_palette_24bit_b_w, &paletteram_2 },
  175.     { 0x0bc000, 0x0bc00f, twocrude_control_w },
  176.     { -1 }  /* end of table */
  177. };
  178.  
  179. /******************************************************************************/
  180.  
  181. static WRITE_HANDLER( YM2151_w )
  182. {
  183.     switch (offset) {
  184.     case 0:
  185.         YM2151_register_port_0_w(0,data);
  186.         break;
  187.     case 1:
  188.         YM2151_data_port_0_w(0,data);
  189.         break;
  190.     }
  191. }
  192.  
  193. static WRITE_HANDLER( YM2203_w )
  194. {
  195.     switch (offset) {
  196.     case 0:
  197.         YM2203_control_port_0_w(0,data);
  198.         break;
  199.     case 1:
  200.         YM2203_write_port_0_w(0,data);
  201.         break;
  202.     }
  203. }
  204.  
  205. static struct MemoryReadAddress sound_readmem[] =
  206. {
  207.     { 0x000000, 0x00ffff, MRA_ROM },
  208.     { 0x100000, 0x100001, YM2203_status_port_0_r },
  209.     { 0x110000, 0x110001, YM2151_status_port_0_r },
  210.     { 0x120000, 0x120001, OKIM6295_status_0_r },
  211.     { 0x130000, 0x130001, OKIM6295_status_1_r },
  212.     { 0x140000, 0x140001, soundlatch_r },
  213.     { 0x1f0000, 0x1f1fff, MRA_BANK8 },
  214.     { -1 }  /* end of table */
  215. };
  216.  
  217. static struct MemoryWriteAddress sound_writemem[] =
  218. {
  219.     { 0x000000, 0x00ffff, MWA_ROM },
  220.     { 0x100000, 0x100001, YM2203_w },
  221.     { 0x110000, 0x110001, YM2151_w },
  222.     { 0x120000, 0x120001, OKIM6295_data_0_w },
  223.     { 0x130000, 0x130001, OKIM6295_data_1_w },
  224.     { 0x1f0000, 0x1f1fff, MWA_BANK8 },
  225.     { 0x1fec00, 0x1fec01, H6280_timer_w },
  226.     { 0x1ff402, 0x1ff403, H6280_irq_status_w },
  227.     { -1 }  /* end of table */
  228. };
  229.  
  230. /******************************************************************************/
  231.  
  232. INPUT_PORTS_START( twocrude )
  233.     PORT_START    /* Player 1 controls */
  234.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  235.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  236.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  237.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  238.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  239.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  240.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  241.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  242.  
  243.     PORT_START    /* Player 2 controls */
  244.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  245.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  246.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  247.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  248.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  249.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  250.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  251.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  252.  
  253.     PORT_START    /* Credits */
  254.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  255.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  256.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  257.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
  258.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  259.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  260.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  261.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  262.  
  263.     PORT_START    /* Dip switch bank 1 */
  264.     PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )
  265.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  266.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  267.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
  268.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
  269.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
  270.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
  271.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_5C ) )
  272.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_6C ) )
  273.     PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )
  274.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  275.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  276.     PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )
  277.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
  278.     PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
  279.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
  280.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
  281.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_6C ) )
  282.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )
  283.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  284.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  285.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
  286.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  287.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  288.  
  289.     PORT_START    /* Dip switch bank 2 */
  290.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  291.     PORT_DIPSETTING(    0x00, "1" )
  292.     PORT_DIPSETTING(    0x01, "2" )
  293.     PORT_DIPSETTING(    0x03, "3" )
  294.     PORT_DIPSETTING(    0x02, "4" )
  295.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
  296.     PORT_DIPSETTING(    0x0c, "Normal" )
  297.     PORT_DIPSETTING(    0x08, "Easy" )
  298.     PORT_DIPSETTING(    0x04, "Hard" )
  299.     PORT_DIPSETTING(    0x00, "Hardest" )
  300.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
  301.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  302.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  303.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
  304.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  305.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  306.     PORT_DIPNAME( 0x40, 0x40, "Allow Continue" )
  307.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  308.     PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
  309.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  310.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  311.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  312. INPUT_PORTS_END
  313.  
  314. /******************************************************************************/
  315.  
  316. static struct GfxLayout charlayout =
  317. {
  318.     8,8,
  319.     4096,
  320.     4,
  321.     { 0x10000*8+8, 8, 0x10000*8, 0 },
  322.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  323.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  324.              },
  325.     16*8
  326. };
  327.  
  328. static struct GfxLayout tilelayout =
  329. {
  330.     16,16,
  331.     4096,
  332.     4,
  333.     { 24, 16, 8, 0 },
  334.     { 64*8+0, 64*8+1, 64*8+2, 64*8+3, 64*8+4, 64*8+5, 64*8+6, 64*8+7,
  335.         0, 1, 2, 3, 4, 5, 6, 7 },
  336.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
  337.             8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
  338.     128*8
  339. };
  340.  
  341. static struct GfxLayout spritelayout =
  342. {
  343.     16,16,
  344.     (4096*2)+2048,  /* Main bank + 4 extra roms */
  345.     4,
  346.     { 0xa0000*8+8, 0xa0000*8, 8, 0 },
  347.     { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7,
  348.         0, 1, 2, 3, 4, 5, 6, 7 },
  349.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  350.             8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  351.     64*8
  352. };
  353.  
  354. static struct GfxDecodeInfo gfxdecodeinfo[] =
  355. {
  356.     { REGION_GFX1, 0, &charlayout,        0, 16 },    /* Characters 8x8 */
  357.     { REGION_GFX2, 0, &tilelayout,  1024, 16 },    /* Tiles 16x16 */
  358.     { REGION_GFX2, 0, &tilelayout,   768, 16 },    /* Tiles 16x16 */
  359.     { REGION_GFX3, 0, &tilelayout,   512, 16 },    /* Tiles 16x16 */
  360.     { REGION_GFX4, 0, &spritelayout, 256, 80 },    /* Sprites 16x16 */
  361.     { -1 } /* end of array */
  362. };
  363.  
  364. /******************************************************************************/
  365.  
  366. static struct OKIM6295interface okim6295_interface =
  367. {
  368.     2,              /* 2 chips */
  369.     { 7757, 15514 },/* Frequency */
  370.     { REGION_SOUND1, REGION_SOUND2 },  /* memory regions 3 & 4 */
  371.     { 50, 25 }        /* Note!  Keep chip 1 (voices) louder than chip 2 */
  372. };
  373.  
  374. static struct YM2203interface ym2203_interface =
  375. {
  376.     1,
  377.     32220000/8,    /* Accurate, audio section crystal is 32.220 MHz */
  378.     { YM2203_VOL(40,40) },
  379.     { 0 },
  380.     { 0 },
  381.     { 0 },
  382.     { 0 }
  383. };
  384.  
  385. static void sound_irq(int state)
  386. {
  387.     cpu_set_irq_line(1,1,state); /* IRQ 2 */
  388. }
  389.  
  390. static struct YM2151interface ym2151_interface =
  391. {
  392.     1,
  393.     32220000/9, /* Accurate, audio section crystal is 32.220 MHz */
  394.     { YM3012_VOL(45,MIXER_PAN_LEFT,45,MIXER_PAN_RIGHT) },
  395.     { sound_irq }
  396. };
  397.  
  398. static struct MachineDriver machine_driver_twocrude =
  399. {
  400.     /* basic machine hardware */
  401.     {
  402.          {
  403.             CPU_M68000,
  404.             12000000, /* Accurate */
  405.             twocrude_readmem,twocrude_writemem,0,0,
  406.             m68_level4_irq,1 /* VBL */
  407.         },
  408.         {
  409.             CPU_H6280 | CPU_AUDIO_CPU,
  410.             32220000/8,    /* Accurate */
  411.             sound_readmem,sound_writemem,0,0,
  412.             ignore_interrupt,0
  413.         }
  414.     },
  415.     58, 529, /* frames per second, vblank duration */
  416.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  417.     0,
  418.  
  419.     /* video hardware */
  420.     32*8, 32*8, { 0*8, 32*8-1, 1*8, 31*8-1 },
  421.  
  422.     gfxdecodeinfo,
  423.     2048, 2048,
  424.     0,
  425.  
  426.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK,
  427.     0,
  428.     twocrude_vh_start,
  429.     twocrude_vh_stop,
  430.     twocrude_vh_screenrefresh,
  431.  
  432.     /* sound hardware */
  433.     0,0,0,0,
  434.       {
  435.         {
  436.             SOUND_YM2203,
  437.             &ym2203_interface
  438.         },
  439.         {
  440.             SOUND_YM2151,
  441.             &ym2151_interface
  442.         },
  443.         {
  444.             SOUND_OKIM6295,
  445.             &okim6295_interface
  446.         }
  447.     }
  448. };
  449.  
  450. /******************************************************************************/
  451.  
  452. ROM_START( cbuster )
  453.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  454.       ROM_LOAD_EVEN( "fx01.rom", 0x00000, 0x20000, 0xddae6d83 )
  455.     ROM_LOAD_ODD ( "fx00.rom", 0x00000, 0x20000, 0x5bc2c0de )
  456.       ROM_LOAD_EVEN( "fx03.rom", 0x40000, 0x20000, 0xc3d65bf9 )
  457.      ROM_LOAD_ODD ( "fx02.rom", 0x40000, 0x20000, 0xb875266b )
  458.  
  459.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  460.     ROM_LOAD( "fu11-.rom",     0x00000, 0x10000, 0x65f20f10 )
  461.  
  462.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  463.     ROM_LOAD( "fu05-.rom",     0x00000, 0x10000, 0x8134d412 ) /* Chars */
  464.     ROM_LOAD( "fu06-.rom",     0x10000, 0x10000, 0x2f914a45 )
  465.  
  466.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  467.     ROM_LOAD( "mab-01",        0x00000, 0x80000, 0x1080d619 ) /* Tiles */
  468.  
  469.     ROM_REGION( 0x80000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  470.     ROM_LOAD( "mab-00",        0x00000, 0x80000, 0x660eaabd ) /* Tiles */
  471.  
  472.     ROM_REGION( 0x180000,REGION_GFX4 | REGIONFLAG_DISPOSE )
  473.     ROM_LOAD( "mab-02",        0x000000, 0x80000, 0x58b7231d ) /* Sprites */
  474.     /* Space for extra sprites to be copied to (0x20000) */
  475.     ROM_LOAD( "mab-03",        0x0a0000, 0x80000, 0x76053b9d )
  476.      /* Space for extra sprites to be copied to (0x20000) */
  477.     ROM_LOAD( "fu07-.rom",     0x140000, 0x10000, 0xca8d0bb3 ) /* Extra sprites */
  478.     ROM_LOAD( "fu08-.rom",     0x150000, 0x10000, 0xc6afc5c8 )
  479.     ROM_LOAD( "fu09-.rom",     0x160000, 0x10000, 0x526809ca )
  480.     ROM_LOAD( "fu10-.rom",     0x170000, 0x10000, 0x6be6d50e )
  481.  
  482.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  483.     ROM_LOAD( "fu12-.rom",     0x00000, 0x20000, 0x2d1d65f2 )
  484.  
  485.     ROM_REGION( 0x20000, REGION_SOUND2 )    /* ADPCM samples */
  486.     ROM_LOAD( "fu13-.rom",     0x00000, 0x20000, 0xb8525622 )
  487. ROM_END
  488.  
  489. ROM_START( cbusterw )
  490.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  491.       ROM_LOAD_EVEN( "fu01-.rom", 0x00000, 0x20000, 0x0203e0f8 )
  492.     ROM_LOAD_ODD ( "fu00-.rom", 0x00000, 0x20000, 0x9c58626d )
  493.       ROM_LOAD_EVEN( "fu03-.rom", 0x40000, 0x20000, 0xdef46956 )
  494.      ROM_LOAD_ODD ( "fu02-.rom", 0x40000, 0x20000, 0x649c3338 )
  495.  
  496.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  497.     ROM_LOAD( "fu11-.rom",     0x00000, 0x10000, 0x65f20f10 )
  498.  
  499.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  500.     ROM_LOAD( "fu05-.rom",     0x00000, 0x10000, 0x8134d412 ) /* Chars */
  501.     ROM_LOAD( "fu06-.rom",     0x10000, 0x10000, 0x2f914a45 )
  502.  
  503.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  504.     ROM_LOAD( "mab-01",        0x00000, 0x80000, 0x1080d619 ) /* Tiles */
  505.  
  506.     ROM_REGION( 0x80000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  507.     ROM_LOAD( "mab-00",        0x00000, 0x80000, 0x660eaabd ) /* Tiles */
  508.  
  509.     ROM_REGION( 0x180000,REGION_GFX4 | REGIONFLAG_DISPOSE )
  510.     ROM_LOAD( "mab-02",        0x000000, 0x80000, 0x58b7231d ) /* Sprites */
  511.     /* Space for extra sprites to be copied to (0x20000) */
  512.     ROM_LOAD( "mab-03",        0x0a0000, 0x80000, 0x76053b9d )
  513.      /* Space for extra sprites to be copied to (0x20000) */
  514.     ROM_LOAD( "fu07-.rom",     0x140000, 0x10000, 0xca8d0bb3 ) /* Extra sprites */
  515.     ROM_LOAD( "fu08-.rom",     0x150000, 0x10000, 0xc6afc5c8 )
  516.     ROM_LOAD( "fu09-.rom",     0x160000, 0x10000, 0x526809ca )
  517.     ROM_LOAD( "fu10-.rom",     0x170000, 0x10000, 0x6be6d50e )
  518.  
  519.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  520.     ROM_LOAD( "fu12-.rom",     0x00000, 0x20000, 0x2d1d65f2 )
  521.  
  522.     ROM_REGION( 0x20000, REGION_SOUND2 )    /* ADPCM samples */
  523.     ROM_LOAD( "fu13-.rom",     0x00000, 0x20000, 0xb8525622 )
  524. ROM_END
  525.  
  526. ROM_START( cbusterj )
  527.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  528.       ROM_LOAD_EVEN( "fr01-1",   0x00000, 0x20000, 0xaf3c014f )
  529.     ROM_LOAD_ODD ( "fr00-1",   0x00000, 0x20000, 0xf666ad52 )
  530.       ROM_LOAD_EVEN( "fr03",     0x40000, 0x20000, 0x02c06118 )
  531.      ROM_LOAD_ODD ( "fr02",     0x40000, 0x20000, 0xb6c34332 )
  532.  
  533.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  534.     ROM_LOAD( "fu11-.rom",     0x00000, 0x10000, 0x65f20f10 )
  535.  
  536.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  537.     ROM_LOAD( "fu05-.rom",     0x00000, 0x10000, 0x8134d412 ) /* Chars */
  538.     ROM_LOAD( "fu06-.rom",     0x10000, 0x10000, 0x2f914a45 )
  539.  
  540.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  541.     ROM_LOAD( "mab-01",        0x00000, 0x80000, 0x1080d619 ) /* Tiles */
  542.  
  543.     ROM_REGION( 0x80000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  544.     ROM_LOAD( "mab-00",        0x00000, 0x80000, 0x660eaabd ) /* Tiles */
  545.  
  546.     ROM_REGION( 0x180000,REGION_GFX4 | REGIONFLAG_DISPOSE )
  547.     ROM_LOAD( "mab-02",        0x000000, 0x80000, 0x58b7231d ) /* Sprites */
  548.     /* Space for extra sprites to be copied to (0x20000) */
  549.     ROM_LOAD( "mab-03",        0x0a0000, 0x80000, 0x76053b9d )
  550.      /* Space for extra sprites to be copied to (0x20000) */
  551.     ROM_LOAD( "fr07",          0x140000, 0x10000, 0x52c85318 ) /* Extra sprites */
  552.     ROM_LOAD( "fr08",          0x150000, 0x10000, 0xea25fbac )
  553.     ROM_LOAD( "fr09",          0x160000, 0x10000, 0xf8363424 )
  554.     ROM_LOAD( "fr10",          0x170000, 0x10000, 0x241d5760 )
  555.  
  556.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  557.     ROM_LOAD( "fu12-.rom",     0x00000, 0x20000, 0x2d1d65f2 )
  558.  
  559.     ROM_REGION( 0x20000, REGION_SOUND2 )    /* ADPCM samples */
  560.     ROM_LOAD( "fu13-.rom",     0x00000, 0x20000, 0xb8525622 )
  561. ROM_END
  562.  
  563. ROM_START( twocrude )
  564.     ROM_REGION( 0x80000, REGION_CPU1 ) /* 68000 code */
  565.     ROM_LOAD_EVEN( "ft01",     0x00000, 0x20000, 0x08e96489 )
  566.     ROM_LOAD_ODD ( "ft00",     0x00000, 0x20000, 0x6765c445 )
  567.     ROM_LOAD_EVEN( "ft03",     0x40000, 0x20000, 0x28002c99 )
  568.     ROM_LOAD_ODD ( "ft02",     0x40000, 0x20000, 0x37ea0626 )
  569.  
  570.     ROM_REGION( 0x10000, REGION_CPU2 )    /* Sound CPU */
  571.     ROM_LOAD( "fu11-.rom",     0x00000, 0x10000, 0x65f20f10 )
  572.  
  573.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  574.     ROM_LOAD( "fu05-.rom",     0x00000, 0x10000, 0x8134d412 ) /* Chars */
  575.     ROM_LOAD( "fu06-.rom",     0x10000, 0x10000, 0x2f914a45 )
  576.  
  577.     ROM_REGION( 0x80000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  578.     ROM_LOAD( "mab-01",        0x00000, 0x80000, 0x1080d619 ) /* Tiles */
  579.  
  580.     ROM_REGION( 0x80000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  581.     ROM_LOAD( "mab-00",        0x00000, 0x80000, 0x660eaabd ) /* Tiles */
  582.  
  583.     ROM_REGION( 0x180000,REGION_GFX4 | REGIONFLAG_DISPOSE )
  584.     ROM_LOAD( "mab-02",        0x000000, 0x80000, 0x58b7231d ) /* Sprites */
  585.     /* Space for extra sprites to be copied to (0x20000) */
  586.     ROM_LOAD( "mab-03",        0x0a0000, 0x80000, 0x76053b9d )
  587.      /* Space for extra sprites to be copied to (0x20000) */
  588.     ROM_LOAD( "ft07",          0x140000, 0x10000, 0xe3465c25 )
  589.     ROM_LOAD( "ft08",          0x150000, 0x10000, 0xc7f1d565 )
  590.     ROM_LOAD( "ft09",          0x160000, 0x10000, 0x6e3657b9 )
  591.     ROM_LOAD( "ft10",          0x170000, 0x10000, 0xcdb83560 )
  592.  
  593.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* ADPCM samples */
  594.     ROM_LOAD( "fu12-.rom",     0x00000, 0x20000, 0x2d1d65f2 )
  595.  
  596.     ROM_REGION( 0x20000, REGION_SOUND2 )    /* ADPCM samples */
  597.     ROM_LOAD( "fu13-.rom",     0x00000, 0x20000, 0xb8525622 )
  598. ROM_END
  599.  
  600. /******************************************************************************/
  601.  
  602. static void init_twocrude(void)
  603. {
  604.     unsigned char *RAM = memory_region(REGION_CPU1);
  605.     unsigned char *PTR;
  606.     int i,j;
  607.  
  608.     /* Main cpu decrypt */
  609.     for (i=0x00000; i<0x80000; i+=2) {
  610. #ifdef LSB_FIRST
  611.         RAM[i+1]=(RAM[i+1] & 0xcf) | ((RAM[i+1] & 0x10) << 1) | ((RAM[i+1] & 0x20) >> 1);
  612.         RAM[i+1]=(RAM[i+1] & 0x5f) | ((RAM[i+1] & 0x20) << 2) | ((RAM[i+1] & 0x80) >> 2);
  613.  
  614.         RAM[i]=(RAM[i] & 0xbd) | ((RAM[i] & 0x2) << 5) | ((RAM[i] & 0x40) >> 5);
  615.         RAM[i]=(RAM[i] & 0xf5) | ((RAM[i] & 0x2) << 2) | ((RAM[i] & 0x8) >> 2);
  616. #else
  617.         RAM[i]=(RAM[i] & 0xcf) | ((RAM[i] & 0x10) << 1) | ((RAM[i] & 0x20) >> 1);
  618.         RAM[i]=(RAM[i] & 0x5f) | ((RAM[i] & 0x20) << 2) | ((RAM[i] & 0x80) >> 2);
  619.  
  620.         RAM[i+1]=(RAM[i+1] & 0xbd) | ((RAM[i+1] & 0x2) << 5) | ((RAM[i+1] & 0x40) >> 5);
  621.         RAM[i+1]=(RAM[i+1] & 0xf5) | ((RAM[i+1] & 0x2) << 2) | ((RAM[i+1] & 0x8) >> 2);
  622. #endif
  623.     }
  624.  
  625.     /* Rearrange the 'extra' sprite bank to be in the same format as main sprites */
  626.     RAM = memory_region(REGION_GFX4) + 0x080000;
  627.     PTR = memory_region(REGION_GFX4) + 0x140000;
  628.     for (i=0; i<0x20000; i+=64) {
  629.         for (j=0; j<16; j+=1) { /* Copy 16 lines down */
  630.             RAM[i+      0+j*2]=PTR[i/2+      0+j]; /* Pixels 0-7 for each plane */
  631.             RAM[i+      1+j*2]=PTR[i/2+0x10000+j];
  632.             RAM[i+0xa0000+j*2]=PTR[i/2+0x20000+j];
  633.             RAM[i+0xa0001+j*2]=PTR[i/2+0x30000+j];
  634.         }
  635.  
  636.         for (j=0; j<16; j+=1) { /* Copy 16 lines down */
  637.             RAM[i+   0x20+j*2]=PTR[i/2+   0x10+j]; /* Pixels 8-15 for each plane */
  638.             RAM[i+   0x21+j*2]=PTR[i/2+0x10010+j];
  639.             RAM[i+0xa0020+j*2]=PTR[i/2+0x20010+j];
  640.             RAM[i+0xa0021+j*2]=PTR[i/2+0x30010+j];
  641.         }
  642.     }
  643. }
  644.  
  645. /******************************************************************************/
  646.  
  647. GAME( 1990, cbuster,  0,       twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FX version)" )
  648. GAME( 1990, cbusterw, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FU version)" )
  649. GAME( 1990, cbusterj, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (Japan)" )
  650. GAME( 1990, twocrude, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East USA", "Two Crude (US)" )
  651.